﻿SetTimer initAll,-400

#Include sys
#Include init.ahk

#Include ../hotkey
#Include sysUtils.ahk
#Include capslock.ahk
;#Include space.ahk
#Include hotstr.ahk
#Include ralt.ahk
#Include keymap.ahk

hotkeyHandler(ThisHotkey){
    ;msgbox "sss" ThisHotkey
    msgbox ThisHotkey
}

hotStringHandlerMap:=Map()

printCurrDate(ThisHotkey){
    currDate := FormatTime(,"yyyyMMdd")
    sendText currDate
}
printCurrTime(ThisHotkey){
    currDate := FormatTime(,"HHmmss")
    sendText currDate
}
hotStringHandlerMap["printCurrDate"]:=printCurrDate
hotStringHandlerMap["printCurrTime"]:=printCurrTime

initAll(){
    ;Gosub space_init
    ; hotstr_init()
    ; ralt_init()
    ; capslock_init()

    hotstringKey:="hotstring"
    hotkeyKey := "hotkey"
    configName := "config.ini"

    sections := IniRead(configName)
    if (InStr(sections,hotstringKey)){
        hotStrConfigs := IniRead(configName,hotstringKey)
        Loop parse, hotStrConfigs, "`n", "`r"{
            strArray := StrSplit(A_LoopField,"=")
            if (hotStringHandlerMap.Has(strArray[2])){
                Hotstring(strArray[1],hotStringHandlerMap.Get(strArray[2]))
            }else{
                Hotstring(strArray[1], strArray[2])
            }
        }
    }

    if (InStr(sections,hotkeyKey)){
        hotKeyConfigs := IniRead(configName,hotkeyKey)
        Loop parse, hotKeyConfigs, "`n", "`r"{
            strArray := StrSplit(A_LoopField,"=")
            Hotkey(strArray[1], hotkeyHandler)
        }
    }

    Suspend True
    Sleep 200
    Suspend False
}